# -*- coding: utf-8 -*-
# @Time    : 2024/11/28 下午9:53
# @Author  : wjx
# @Email   : kanxinxin@163.com
# @File    : base_test_case.py
# @Software: PyCharm
import unittest
from appium import webdriver
from appium.options.android import UiAutomator2Options


class BaseTestCase(unittest.TestCase):
    capabilities = dict(
        platformName='Android',
        automationName='uiautomator2',
        deviceName='e263316a',
        appPackage='com.xiachufang',
        appActivity='.startpage.ui.StartPageActivity',
        noReset=True,
        forceAppLaunch=True,
        shouldTerminateApp=True
    )

    appium_server_url = 'http://127.0.0.1:4723'

    # @classmethod
    # def setUpClass(cls):
    #准备图片数据
    # driver.get_screenshot_as_file(r'E:\blog\blog_script\images\test_login_error_01.png')
    # driver.save_screenshot('test_login_error_02.png')

    def setUp(self):
        self.driver = webdriver.Remote(self.appium_server_url,
                                       options=UiAutomator2Options().load_capabilities(self.capabilities)
                                       )

    def tearDown(self):
        if self.driver:
            self.driver.quit()

    def swipe_page(self):
        start_x = 725
        start_y = 2330
        end_x = 725
        end_y = 940
        self.driver.swipe(start_x, start_y, end_x, end_y, duration=2000)


if __name__ == '__main__':
    unittest.main()
